import * as PIXI from 'pixi.js'
import { setPixi } from '@/store/modules/usePixiStore'
import useDiyStore from '@/store/modules/useDiyStore'
import modal from './modal'
import diyBg from './diyBg'
import close from './close'
import option from './option'
import preview from './preview'

export default async () => {
  const diyStore = useDiyStore()
  const container = new PIXI.Container({
    visible: diyStore.visible,
  })
  const modalContainer = modal() // 模态框
  const diyBgContainer = await diyBg() // 背景
  const optionContainer = await option() // 选项
  const previewContainer = await preview() // 预览
  const closeContainer = await close() // 关闭按钮
  container.addChild(modalContainer) // 模态框
  container.addChild(diyBgContainer) // 背景
  container.addChild(optionContainer) // 选项
  container.addChild(previewContainer) // 预览
  container.addChild(closeContainer) // 关闭按钮
  setPixi('diyModal', container)
  return container
}
